fix(landing): load sharp lazily so a missing native binary can't 500 /blog and /library - #6496
Conversation
…/blog and /library
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThe PR prevents a missing Sharp native binary from taking down landing-page content routes and simplifies the Platform navigation grid.
Confidence Score: 5/5The PR appears safe to merge, with Sharp load failures contained as intended and no actionable regressions identified. The lazy import and metadata extraction execute within the same error boundary, the fallback behavior is regression-tested, and the navigation change is a self-contained layout simplification.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/content/registry-factory.ts | Lazily imports Sharp within the existing fallback boundary, ensuring native-module failures no longer prevent content registries from loading. |
| apps/sim/lib/content/registry-factory.test.ts | Adds focused regression coverage proving registry listing and slug resolution survive a Sharp import failure. |
| apps/sim/app/(landing)/components/navbar/components/nav-menu-chip/nav-menu-chip.tsx | Simplifies the menu layout to a conventional three-column grid that leaves incomplete-row space at the bottom right. |
| apps/sim/app/(landing)/components/navbar/components/nav-menu-chip/constants.ts | Updates Platform-menu documentation to match the five-item, three-column layout. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Content registry reads post frontmatter] --> B{OG image is local}
B -- No --> C[Skip dimension extraction]
B -- Yes --> D[Read image file]
D --> E[Lazy import Sharp]
E -->|Available| F[Extract width and height]
E -->|Missing native binary| G[Log warning]
D -->|Read failure| G
F --> H[Return dimensions]
G --> I[Return null]
I --> J[Use default OG dimensions]
C --> J
Reviews (1): Last reviewed commit: "fix(landing): load sharp lazily so a mis..." | Re-trigger Greptile
PR SummaryMedium Risk Overview
Adds Landing nav: the mega-menu panel drops the six-track grid and Reviewed by Cursor Bugbot for commit cd4f714. Configure here. |
Summary
/blog,/library, and every tag, author, slug, and RSS route under them are returning 500 in production. Root cause confirmed in CloudWatch:Failed to load external module sharp — ERR_DLOPEN_FAILED: libvips-cpp.so.8.18.3: cannot open shared object file, thrown fromexternalImportwith no catch frame.image-sizewithsharpand imported it at the top level oflib/content/registry-factory.ts. sharp's native binary is not present in the runtime image, so that import throws at module scope and takes down every route that touches the content registry — instead of degrading one optional OG dimension.try, matching the guarded dynamic importlib/copilot/vfs/file-reader.tsalready uses against this exact failure. Log the fallback instead of swallowing it silently.col-start-2centering so the Platform menu's five tiles leave their gap in the bottom-right corner rather than staggering.Follow-ups (not in this PR)
outputFileTracingIncludesglobs./node_modules/sharp/**/*and./node_modules/@img/**/*, but those resolve againstapps/simwhile both hoist to the monorepo root, so they match nothing (same trapdocker/app.Dockerfilealready documents foryjs/lib0).Type of Change
Testing
lib/content/registry-factory.test.tsmockssharpto fail exactly as production does; verified it goes red on the current code (module-load throw, 0 tests run) and green with the fix.bun run type-check,bun run lint, andbunx vitest run lib/content(44 passed).node_modules).Checklist